package com.quanyue.haircut.shop.service.impl;

import com.quanyue.haircut.domain.entity.Activity;
import com.quanyue.haircut.shop.mapper.ActivityMapper;
import com.quanyue.haircut.shop.service.ActivityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

@Service
public class ActivityServiceImpl implements ActivityService {
    @Autowired
    private ActivityMapper activityMapper;

    @Override
    public List <Activity> findActivity(Integer merchantNo) {
        return activityMapper.findByMerchantNo(merchantNo);
    }

    @Override
    public Activity createActivity(Activity activity) {
        activity.setCreateTime(LocalDateTime.now());
        activityMapper.insert(activity);
        return activity;
    }

    @Override
    public void updateActivity(Activity activity) {
        activityMapper.updateSelective(activity);
    }

    @Override
    public void deleteActivity(Integer activityId) {
        activityMapper.deleteOne(activityId);
    }
}
